﻿package org.openChart.display 
{
	import org.openChart.meta.TextLabel;
	import org.openChart.util.Rectangle;
	
	/**
	 * ...
	 * @author Chongyuan
	 */
	public class DisplayScreenTitle extends DisplayTextLabel //implements DisplayInterface
	{
		private var layout_:String = TOP;
		private var parent_:DisplayScreen;
		
		public static const TOP:String = "top";
		public static const BOTTOM:String = "bottom";
		
		public function DisplayScreenTitle(textLabel:TextLabel, screen:DisplayScreen) 
		{
			this.parent_ = screen;
			super(textLabel);
			align = "center-top";
		}
		
		public override function initialize():void
		{
			super.initialize();
		}
		
		public override function resize(rectagle:Rectangle):void
		{
			if (layout == DisplayScreenTitle.TOP)
			{
				this.position.y = rectagle.top ;
				rectagle.top += this.height;
			}
			else if (layout == DisplayScreenTitle.BOTTOM)
			{
				rectagle.bottom -= this.height;
				position.y = rectagle.bottom;
			}
			position.x = (rectagle.left + rectagle.right) / 2;
		}
		
		public function set layout( layout_:String ):void 
		{
			this.layout_ = layout_;
		}
		
		public function get layout():String
		{
			return this.layout_;
		}
		
		public function get parent():DisplayScreen
		{
			return parent_;
		}
		
		public override function toString():String
		{
			return super.toString();
		}
	}
	
}